home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-src / vsc / vsc.h < prev   
C/C++ Source or Header  |  1999-01-01  |  5KB  |  122 lines

  1. /*  vsc portable scheduler (c) 1997-99 by Volker Barthelmann */
  2.  
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <limits.h>
  7.  
  8. #define BSET(array,bit) (array)[(bit)/CHAR_BIT]|=1<<((bit)%CHAR_BIT)
  9. #define BCLR(array,bit) (array)[(bit)/CHAR_BIT]&=~(1<<((bit)%CHAR_BIT))
  10. #define BTST(array,bit) ((array)[(bit)/CHAR_BIT]&(1<<((bit)%CHAR_BIT)))
  11.  
  12. /* An instruction with LABEL set is preceded with a numbered label. */
  13. /* The number is in <label>.                                        */
  14. #define LABEL 1
  15.  
  16. /* An instrution with COND_BRANCH set may be followed by the next */
  17. /* instruction or by the instruction with the label in <label>.   */
  18. #define COND_BRANCH 2
  19.  
  20. /* An instruction with UNCOND_BRANCH set is followed by the */
  21. /* instruction with the label in <label>.                   */
  22. #define UNCOND_BRANCH 4
  23.  
  24. /* The side-effects of an instruction with BARRIER set cannot entirely */
  25. /* be specified by a struct sinfo (e.g. function-calls, pseudo-ops or  */
  26. /* other complicated things). vsc will not move any code across this   */
  27. /* instruction.                                                        */
  28. #define BARRIER 8
  29.  
  30. /* An instruction with neither COND_BRANCH, UNCOND_BRANCH nor BARRIER  */
  31. /* set _must_ _not_ change control-flow.                               */
  32.  
  33. /* Used by vsched.c. */
  34. #define OUT 16
  35. #define READY 32
  36.  
  37. /* schedule.h has to #define REGS (the maximum number of registers */
  38. /* (numbered from 0 to REGS-1) and the maximum number of pipelines */
  39. /* PIPES (numbered from 0 to PIPES-1). If multiple CPUs with       */
  40. /* different numbers of pipelines or registers are supported the   */
  41. /* largest number must be specified. The CPU-differences must be   */
  42. /* represented by the information provided by sched_info().        */
  43. #include "schedule.h"
  44.  
  45. /* MEM is a pseudo-register used to indicate that memory is        */
  46. /* accessed.                                                       */
  47. #define MEM REGS
  48.  
  49. #define PIPES_SIZE ((PIPES+CHAR_BIT-1)/CHAR_BIT*CHAR_BIT)
  50. #define REGS_SIZE ((MEM+1+CHAR_BIT-1)/CHAR_BIT*CHAR_BIT)
  51.  
  52. /* The struct to hold scheduling-information on an instruction. */
  53. struct sinfo {
  54.   /* The instruction in assembly-language. */
  55.   char *txt;
  56.  
  57.   /* A combination of the flags mentioned above. */
  58.   unsigned int flags;
  59.  
  60.   /* A numbered label used with LABEL, COND_BRANCH and UNCOND_BRANCH. */
  61.   unsigned int label;
  62.  
  63.   /* Number of cycles until all side-effects of the operation are */
  64.   /* completed. */
  65.   unsigned int latency;
  66.  
  67.   /* Bit-vector which contains 1s for every pipeline which can execute */
  68.   /* this instruction. */
  69.   unsigned char pipes[PIPES_SIZE];
  70.  
  71.   /* Bit-vector which contains 1s for every register that is used by */
  72.   /* this instruction. Use pseudo-register MEM if it reads memory.   */
  73.   unsigned char uses[REGS_SIZE];
  74.  
  75.   /* Bit-vector which contains 1s for every register that is modified  */
  76.   /* by this instruction. Use pseudo-register MEM if it writes memory. */
  77.   unsigned char modifies[REGS_SIZE];
  78.  
  79.   /* An ID which identifies the memory-object which is read. 0 means    */
  80.   /* no further information available. Two accesses with different IDs  */
  81.   /* are guaranteed not to access the same memory.                      */
  82.   unsigned long memread_id;
  83.  
  84.   /* An ID which identifies the memory-object which is written. 0 means */
  85.   /* no further information available. Two accesses with different IDs  */
  86.   /* are guaranteed not to access the same memory.                      */
  87.   unsigned long memwrite_id;
  88.  
  89.   /* If this flag is set to 1 then the write to the object with the     */
  90.   /* ID specified by memwrite_id completely overwrites the object.      */
  91.   unsigned int memwrite_completely;
  92. };
  93.  
  94.  
  95. /* Target-specific data which must be provided by schedule.c. */
  96.  
  97. /* Copyright notice which is printed if -quiet is not specified. */
  98. extern char tg_copyright[];
  99.  
  100.  
  101. /* Target-specific functions which must be provided by schedule.c */
  102.  
  103. /* This function allows some initializations to be done. If       */
  104. /* zero is returned vsc assumes an error has happened and aborts. */
  105. extern int sched_init(void);
  106.  
  107. /* This function allows some cleanup before vsc exits. */
  108. extern void sched_cleanup(void);
  109.  
  110. /* This is the main target-specific function. It will be called with  */
  111. /* a pointer to a struct sinfo that is set to binary zeroes except    */
  112. /* for the member <txt> which points to the assembly representation   */
  113. /* of the instruction.                                                */
  114. /* sched_info() has to fill in all the other members with information */
  115. /* that correctly represents the instruction.                         */
  116. /* If the BARRIER-flag is set all other informations are basically    */
  117. /* irrelevant.                                                        */
  118. extern int sched_info(struct sinfo *);
  119.  
  120.  
  121.  
  122.